Code snippet
- 20 Jun 2025
- 1 Minutt å lese
- Bidragsytere
- Skrive ut
- MørkLys
Code snippet
- Oppdatert 20 Jun 2025
- 1 Minutt å lese
- Bidragsytere
- Skrive ut
- MørkLys
The content is currently unavailable in Norwegian. You are viewing the default English version.
Sammendrag av artikkel
Synes du dette sammendraget var nyttig?
Takk for tilbakemeldingen
Creating web application
This web application is built using a lightweight web framework. The app defines a route at the root URL ("/"), which responds to requests by rendering a web page using an HTML file. The HTML file is stored in a folder specifically meant for templates. When a user accesses the homepage through a browser, the server responds with a static HTML page. The server is started using a standard method that runs the application on a local development server.
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def home():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome Page</title>
</head>
<body>
<h1>Hello, welcome to the Flask HTML page!</h1>
<p>This is a simple HTML page rendered by Flask.</p>
</body>
</html>
Var denne artikkelen nyttig?